package com.k.kc.common;

/**
 * 常量信息
 * @author kivil
 */
public final class ConstantType {
    /**
     *  Common Constant
     */
    public final static int SUCCESS = 0;
    public final static int ERROR = -1;

    /**
     * Custom Constant
     */
    public static class SexType {
        public final static int MALE = 1;
        public final static int FEMALE = 2;
    }

    /**
     * Custom Constant
     */
    public static class DeviceType {
        public final static int UNREGISTERED = 101;
        public final static int REGISTERED = 102;
    }

    public enum ActionType {
        INSERT(1,"add")
        ,DELETE(2,"del")
        ,UPDATE(3,"edit")
        ,SELECT(4,"query");

        private int codeInt;
        private String codeStr;
        ActionType(int i,String s) {
            this.codeInt = i;
            this.codeStr = s;
        }

        public int getCodeInt() {
            return codeInt;
        }

        public String getCodeStr() {
            return codeStr;
        }
        public static String findStrByInt(int i){
            for (ActionType item : ActionType.values()) {
                if (item.getCodeInt() == i) {
                    return item.getCodeStr();
                }
            }
            return null;
        }

        public static int findIntByStr(String str){
            for (ActionType item : ActionType.values()) {
                if (item.getCodeStr().equals(str.toUpperCase())) {
                    return item.getCodeInt();
                }
            }
            return 0;
        }
    }
}
